home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 72 / IOPROG_72.ISO / soft / c++ / NCTDiscWriter2.exe / {app} / MS C# 7.0 Samples / TestCSDataCDWriter / frmChooseRec.cs < prev    next >
Encoding:
Text File  |  2003-04-08  |  9.1 KB  |  283 lines

  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6.  
  7. namespace DiskWriter
  8. {
  9.     /// <summary>
  10.     /// Summary description for frmChooseRec.
  11.     /// </summary>
  12.     public class frmChooseRec : System.Windows.Forms.Form
  13.     {
  14.         internal System.Windows.Forms.ComboBox driveCombo;
  15.         internal System.Windows.Forms.GroupBox GroupBox1;
  16.         internal System.Windows.Forms.Label Label4;
  17.         internal System.Windows.Forms.CheckBox BurnProofChk;
  18.         internal System.Windows.Forms.Label driveBufferSizeLbl;
  19.         internal System.Windows.Forms.Label driveMaxRSpeedLbl;
  20.         internal System.Windows.Forms.Label driveMaxWSpeedLbl;
  21.         internal System.Windows.Forms.Label Label3;
  22.         internal System.Windows.Forms.Label Label2;
  23.         internal System.Windows.Forms.Label Label1;
  24.         internal System.Windows.Forms.Button cmdOK;
  25.         /// <summary>
  26.         /// Required designer variable.
  27.         /// </summary>
  28.         private System.ComponentModel.Container components = null;
  29.  
  30.         public Form1 frm;
  31.         Int32 driveNum;
  32.  
  33.         public frmChooseRec()
  34.         {
  35.             //
  36.             // Required for Windows Form Designer support
  37.             //
  38.             InitializeComponent();
  39.  
  40.             //
  41.             // TODO: Add any constructor code after InitializeComponent call
  42.             //
  43.         }
  44.  
  45.         /// <summary>
  46.         /// Clean up any resources being used.
  47.         /// </summary>
  48.         protected override void Dispose( bool disposing )
  49.         {
  50.             if( disposing )
  51.             {
  52.                 if(components != null)
  53.                 {
  54.                     components.Dispose();
  55.                 }
  56.             }
  57.             base.Dispose( disposing );
  58.         }
  59.  
  60.         #region Windows Form Designer generated code
  61.         /// <summary>
  62.         /// Required method for Designer support - do not modify
  63.         /// the contents of this method with the code editor.
  64.         /// </summary>
  65.         private void InitializeComponent()
  66.         {
  67.             this.driveCombo = new System.Windows.Forms.ComboBox();
  68.             this.GroupBox1 = new System.Windows.Forms.GroupBox();
  69.             this.Label4 = new System.Windows.Forms.Label();
  70.             this.BurnProofChk = new System.Windows.Forms.CheckBox();
  71.             this.driveBufferSizeLbl = new System.Windows.Forms.Label();
  72.             this.driveMaxRSpeedLbl = new System.Windows.Forms.Label();
  73.             this.driveMaxWSpeedLbl = new System.Windows.Forms.Label();
  74.             this.Label3 = new System.Windows.Forms.Label();
  75.             this.Label2 = new System.Windows.Forms.Label();
  76.             this.Label1 = new System.Windows.Forms.Label();
  77.             this.cmdOK = new System.Windows.Forms.Button();
  78.             this.GroupBox1.SuspendLayout();
  79.             this.SuspendLayout();
  80.             // 
  81.             // driveCombo
  82.             // 
  83.             this.driveCombo.Location = new System.Drawing.Point(8, 8);
  84.             this.driveCombo.Name = "driveCombo";
  85.             this.driveCombo.Size = new System.Drawing.Size(284, 21);
  86.             this.driveCombo.TabIndex = 1;
  87.             this.driveCombo.Text = "Drive Name";
  88.             this.driveCombo.SelectedIndexChanged += new System.EventHandler(this.driveCombo_SelectedIndexChanged);
  89.             // 
  90.             // GroupBox1
  91.             // 
  92.             this.GroupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {
  93.                                                                                     this.Label4,
  94.                                                                                     this.BurnProofChk,
  95.                                                                                     this.driveBufferSizeLbl,
  96.                                                                                     this.driveMaxRSpeedLbl,
  97.                                                                                     this.driveMaxWSpeedLbl,
  98.                                                                                     this.Label3,
  99.                                                                                     this.Label2,
  100.                                                                                     this.Label1});
  101.             this.GroupBox1.Location = new System.Drawing.Point(8, 40);
  102.             this.GroupBox1.Name = "GroupBox1";
  103.             this.GroupBox1.Size = new System.Drawing.Size(283, 142);
  104.             this.GroupBox1.TabIndex = 2;
  105.             this.GroupBox1.TabStop = false;
  106.             this.GroupBox1.Text = "Properties";
  107.             // 
  108.             // Label4
  109.             // 
  110.             this.Label4.Location = new System.Drawing.Point(34, 116);
  111.             this.Label4.Name = "Label4";
  112.             this.Label4.Size = new System.Drawing.Size(124, 18);
  113.             this.Label4.TabIndex = 7;
  114.             this.Label4.Text = "Burn-Proof Support";
  115.             // 
  116.             // BurnProofChk
  117.             // 
  118.             this.BurnProofChk.Enabled = false;
  119.             this.BurnProofChk.Location = new System.Drawing.Point(13, 115);
  120.             this.BurnProofChk.Name = "BurnProofChk";
  121.             this.BurnProofChk.Size = new System.Drawing.Size(16, 18);
  122.             this.BurnProofChk.TabIndex = 6;
  123.             this.BurnProofChk.Text = "Burn-Proof Support";
  124.             // 
  125.             // driveBufferSizeLbl
  126.             // 
  127.             this.driveBufferSizeLbl.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
  128.             this.driveBufferSizeLbl.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
  129.             this.driveBufferSizeLbl.Location = new System.Drawing.Point(134, 78);
  130.             this.driveBufferSizeLbl.Name = "driveBufferSizeLbl";
  131.             this.driveBufferSizeLbl.Size = new System.Drawing.Size(140, 18);
  132.             this.driveBufferSizeLbl.TabIndex = 5;
  133.             this.driveBufferSizeLbl.Text = "0";
  134.             this.driveBufferSizeLbl.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
  135.             // 
  136.             // driveMaxRSpeedLbl
  137.             // 
  138.             this.driveMaxRSpeedLbl.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
  139.             this.driveMaxRSpeedLbl.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
  140.             this.driveMaxRSpeedLbl.Location = new System.Drawing.Point(134, 54);
  141.             this.driveMaxRSpeedLbl.Name = "driveMaxRSpeedLbl";
  142.             this.driveMaxRSpeedLbl.Size = new System.Drawing.Size(140, 18);
  143.             this.driveMaxRSpeedLbl.TabIndex = 4;
  144.             this.driveMaxRSpeedLbl.Text = "0";
  145.             this.driveMaxRSpeedLbl.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
  146.             // 
  147.             // driveMaxWSpeedLbl
  148.             // 
  149.             this.driveMaxWSpeedLbl.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
  150.             this.driveMaxWSpeedLbl.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
  151.             this.driveMaxWSpeedLbl.Location = new System.Drawing.Point(134, 31);
  152.             this.driveMaxWSpeedLbl.Name = "driveMaxWSpeedLbl";
  153.             this.driveMaxWSpeedLbl.Size = new System.Drawing.Size(140, 18);
  154.             this.driveMaxWSpeedLbl.TabIndex = 3;
  155.             this.driveMaxWSpeedLbl.Text = "0";
  156.             this.driveMaxWSpeedLbl.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
  157.             // 
  158.             // Label3
  159.             // 
  160.             this.Label3.Location = new System.Drawing.Point(14, 81);
  161.             this.Label3.Name = "Label3";
  162.             this.Label3.Size = new System.Drawing.Size(104, 15);
  163.             this.Label3.TabIndex = 2;
  164.             this.Label3.Text = "Buffer Size:";
  165.             // 
  166.             // Label2
  167.             // 
  168.             this.Label2.Location = new System.Drawing.Point(14, 57);
  169.             this.Label2.Name = "Label2";
  170.             this.Label2.Size = new System.Drawing.Size(104, 15);
  171.             this.Label2.TabIndex = 1;
  172.             this.Label2.Text = "Read Max Speed:";
  173.             // 
  174.             // Label1
  175.             // 
  176.             this.Label1.Location = new System.Drawing.Point(14, 34);
  177.             this.Label1.Name = "Label1";
  178.             this.Label1.Size = new System.Drawing.Size(104, 15);
  179.             this.Label1.TabIndex = 0;
  180.             this.Label1.Text = "Write Max Speed:";
  181.             // 
  182.             // cmdOK
  183.             // 
  184.             this.cmdOK.Location = new System.Drawing.Point(192, 192);
  185.             this.cmdOK.Name = "cmdOK";
  186.             this.cmdOK.Size = new System.Drawing.Size(95, 25);
  187.             this.cmdOK.TabIndex = 3;
  188.             this.cmdOK.Text = "OK";
  189.             this.cmdOK.Click += new System.EventHandler(this.cmdOK_Click);
  190.             // 
  191.             // frmChooseRec
  192.             // 
  193.             this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  194.             this.ClientSize = new System.Drawing.Size(296, 221);
  195.             this.Controls.AddRange(new System.Windows.Forms.Control[] {
  196.                                                                           this.cmdOK,
  197.                                                                           this.GroupBox1,
  198.                                                                           this.driveCombo});
  199.             this.Name = "frmChooseRec";
  200.             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  201.             this.Text = "frmChooseRec";
  202.             this.Load += new System.EventHandler(this.frmChooseRec_Load);
  203.             this.GroupBox1.ResumeLayout(false);
  204.             this.ResumeLayout(false);
  205.  
  206.         }
  207.         #endregion
  208.  
  209.         private void frmChooseRec_Load(object sender, System.EventArgs e)
  210.         {
  211.             string DriveName = "";
  212.             frm = (Form1)this.Owner;
  213.  
  214.             driveCombo.Items.Clear();
  215.             for(short driveNum = 0; driveNum<frm.DataCDWriter1.driveCount ; driveNum++)
  216.             {
  217.                 frm.DataCDWriter1.driveNum = (short)(driveNum + 1);
  218.                 DriveName = " " + frm.DataCDWriter1.driveVendor + "  " + frm.DataCDWriter1.driveModel + "  " + frm.DataCDWriter1.driveFirmwareVersion;
  219.                 driveCombo.Items.Add(DriveName);
  220.             }
  221.  
  222.             if( driveCombo.Items.Count > 0 )
  223.             {
  224.                 driveCombo.SelectedIndex = 0;
  225.             }
  226.             this.driveNum = frm.DataCDWriter1.driveNum;
  227.             RefreshDriveInfo();
  228.         }
  229.         private void RefreshDriveInfo()
  230.         {
  231.             Int32 MaxSpeed = 0;
  232.             MaxSpeed = frm.DataCDWriter1.driveMaxRSpeed;
  233.             if( MaxSpeed > 0 )
  234.             {
  235.                 driveMaxRSpeedLbl.Text = MaxSpeed + "-x";
  236.             }
  237.             else
  238.             {
  239.                 driveMaxRSpeedLbl.Text = "N/A";
  240.             }
  241.  
  242.             MaxSpeed = frm.DataCDWriter1.driveMaxWSpeed;
  243.             if( MaxSpeed > 0 )
  244.             {
  245.                 driveMaxWSpeedLbl.Text = MaxSpeed + "-x";
  246.             }
  247.             else
  248.             {
  249.                 driveMaxWSpeedLbl.Text = "N/A";
  250.             }
  251.         
  252.             if( frm.DataCDWriter1.driveBurnProofEnabled )
  253.             {
  254.                 BurnProofChk.CheckState.Equals(true);
  255.             }
  256.             else 
  257.             {
  258.                 BurnProofChk.CheckState.Equals(false);
  259.             }
  260.         
  261.             Int32 w = (frm.DataCDWriter1.driveBufferSize / 1024) / 1024;
  262.             driveBufferSizeLbl.Text = w.ToString() + " MB";
  263.         }
  264.  
  265.         private void cmdOK_Click(object sender, System.EventArgs e)
  266.         {
  267.             this.Hide();
  268.         }
  269.  
  270.         private void driveCombo_SelectedIndexChanged(object sender, System.EventArgs e)
  271.         {
  272.             // TODO change drive
  273.  
  274.             int CurDrive = 0;
  275.             CurDrive = driveCombo.SelectedIndex;
  276.             frm.DataCDWriter1.driveNum = (short)(CurDrive + 1);
  277.             frm.RefreshDiskInfo();
  278.             RefreshDriveInfo();
  279.             frm.Refresh();
  280.         }
  281.     }
  282. }
  283.